package com.goldentrail.db;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 
 * 
 * @author Dey, Saumen
 * @version 1.0, Oct 09, 2011
 *
 */
public class DBConnection {

	Connection con = null;
	
	public  void getLocalConnection() throws Exception{
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/goldentrail";
		String username = "root";
		String password = "";
		Class.forName(driver);
		con = DriverManager.getConnection(url, username, password);
	}
	
	public void getGlobalConnection() throws Exception{
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://kelor.genomecenter.ucdavis.edu:3306/goldentrail";
		String username = "datatol";
		String password = "d@t@t0l11";
		Class.forName(driver);
		con = DriverManager.getConnection(url, username, password);
	}
	
	public Connection getConnection(boolean isLocal) throws Exception{
	    if (isLocal) {
	    	getLocalConnection();
	    } else {
	    	getGlobalConnection();
	    }
		return con;
	}

}
